#include<bits/stdc++.h>
using namespace std;
int n,ans;
priority_queue<int,vector<int>,greater<int> > q;
priority_queue<int,vector<int>,greater<int> > p;
void check()
{
    int w=q.top();
    while(!q.empty()&& w==q.top())
    {
        p.push(q.top());
        q.pop();
    }
}
int main()
{
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        q.push(x);
    }
    int x=q.top();
    while(!q.empty() && x==q.top())
    {
        //cout<<q.top()<<" ";
        p.push(q.top());
        q.pop();
    }
    while( !q.empty() )
    {
        if(p.top()==q.top())
        {
  //          cout<<p.top()<<endl;
            check();
        }
        p.pop();
        p.push(q.top());
        q.pop();
    }
    while(!q.empty())
    {
        ans++;
        q.pop();
        //cout<<ans<<endl;
    }
    while(!p.empty())
    {
        ans++;
        p.pop();
    }
    cout<<ans;
    return 0;
}
